package com.sgcc.ln.pmos.e_ln_order.activity;

import android.text.TextUtils;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.blankj.utilcode.util.GsonUtils;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.ln.pmos.arouter.order.OrderArouterPath;
import com.sgcc.ln.pmos.common.base.BaseActivity;
import com.sgcc.ln.pmos.common.widget.TitleBar;
import com.sgcc.ln.pmos.e_ln_order.adapter.SupplementDifferenceAdapter;
import com.sgcc.ln.pmos.e_ln_order.bean.AddSupplementContractItemBean;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 查看补充差价
 */
@Route(path = OrderArouterPath.ORDER_SUPPLEMENTDIFFERENCE)
public class SupplementDifferenceActivity extends BaseActivity {

    private TitleBar mTitleBar;
    private RecyclerView mRvContent;
    private SupplementDifferenceAdapter mSupplementDifferenceAdapter;

    @Autowired
    public String monthlyDifprice;

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_supplementdifference;
    }

    @Override
    protected void initViews() {
        super.initViews();
        mTitleBar = (TitleBar) findViewById(R.id.title_bar);
        mRvContent = (RecyclerView) findViewById(R.id.rv_content);
        mSupplementDifferenceAdapter = new SupplementDifferenceAdapter();
        mRvContent.setAdapter(mSupplementDifferenceAdapter);

        mTitleBar.setTitle("查看补充差价");
        mTitleBar.setRightIcon(R.mipmap.go_main, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                goMainActivity();
            }
        });

        if (!TextUtils.isEmpty(monthlyDifprice)) {
            List<AddSupplementContractItemBean> list = new ArrayList<>();
            Map<String, String> map = GsonUtils.fromJson(monthlyDifprice, Map.class);
            for (String s : map.keySet()) {
                list.add(new AddSupplementContractItemBean(s.replace("-", "年") + "月",
                        "", map.get(s)));
            }
            mSupplementDifferenceAdapter.setList(list);
        }
    }
}
